package com.example.demo.model;

import com.example.demo.enums.ResultCode;
import lombok.Data;

@Data
public class Result<T> {
    public ResultCode code;  //200 成功登录 -1 未登录  -2异常
    public String errorMsg;
    public T data;

    public static<T> Result<T> getSuccess(T data){
        Result<T> result=new Result<>();
        result.setCode(ResultCode.SUCCESS);
        result.setData(data);
        return result;
    }

    public static <T> Result<T> getUnLogin(String msg){
        Result<T> result=new Result<>();
        result.setCode(ResultCode.UNLOGIN);
        result.setErrorMsg(msg);
        return result;

    }

    public static <T> Result<T> getException(String msg){
        Result<T> result=new Result<>();
        result.setCode(ResultCode.EXCEPTION);
        result.setErrorMsg(msg);
        return result;
    }
}
